﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Com.CMS263.PO;

namespace Com.CMS263.DAO
{
    public class CertificationDAO
    {
        public CertificationDAO() { }

        public bool Add(Certification cert)
        {
            try
            {
                DBHelper.TransSaveOrUpdate(cert);
                return true;
            }
            catch 
            {
                return false;
            }
        }
        public bool Modify(Certification cert)
        {
            try
            {
                DBHelper.TransUpdate(cert);
                return true;
            }
            catch
            {
                return false;
            }
        }
        public bool DeleteById(int id)
        {
            try
            {
                DBHelper.ExecuteHQL("delete from Certification where id="+id);
                return true;
            }
            catch
            {
                return false;
            }
        }
        public IList<Certification> GetAllCert(int top)
        {
            try
            {
                return DBHelper.ExecuteHQL("from Certification where isShow=1 order by orderId desc ").SetFirstResult(0).SetMaxResults(top).List<Certification>();
            }
            catch 
            {

                return DBHelper.ExecuteHQL("from Certification where isShow=1 order by orderId desc ").List<Certification>();
            }
           
        }

    }
}
